$(document).ready(function() {	
	$("#frmAdd").validate({
		errorClass		: 'error',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		rules: {							
			pname:{
				required				: true,
				minlength				: VL_NAME_MINLENGTH
			},
			pimage: {
				required				: true,
				validateImgFormat		: true,
				validateImgSize			: true
			},				
			pshort: {								
				maxlength				: VL_SHORT_MAXLENGTH
			},
			plink: {
				url						: true
			}
		},
		messages: {				
			pname:{
				required				: name_required,
				minlength				: name_minlength
			},		
			pimage: {
				required				: image_required,
				validateImgFormat		: image_format,
				validateImgSize			: image_size
			},			
			pshort: {				
				maxlength				: short_maxlength
			},
			plink: {
				url						: link_format
			}
		},
		errorPlacement: function(label, element) {
			var id = element.attr('id');	
			if(id == "pcontent") {			
				label.insertAfter($('#pcontent___Frame'));
			} else {
				label.insertAfter($('#' + id));			
			}
			
		}				 
	});
	$.validator.addMethod('validateImgFormat', function() {
		var strLinkImage = $('#pimage').val();
		if(strLinkImage == "") {
			return false;
		}
		return validateImage(strLinkImage);
	});
	$.validator.addMethod('validateImgSize', function() {
		var strLinkImage = $('#pimage').val();
		if(strLinkImage == "") {
			return false;
		}
		return validateImgSize("pimage");
	});		
});